<%@ Page Language="C#" AutoEventWireup="true" CodeFile="onpage_checkout1.aspx.cs" Inherits="InterpriseSuiteEcommerce.checkout1" %>

<%@ Register Assembly="InterpriseSuiteEcommerceControls" Namespace="InterpriseSuiteEcommerceControls.Validators"
    TagPrefix="ise" %>
<%@ Register Assembly="InterpriseSuiteEcommerceControls" Namespace="InterpriseSuiteEcommerceControls"
    TagPrefix="ise" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>CheckoutOne</title>
    <script type="text/javascript">

        window.onload = function () {

            var chkAddrInfo = document.getElementById('hidCheck');

            var strBTitl = document.getElementById('hidBillTitle');
            var strSTitl = document.getElementById('hidShipTitle');

            var strBChck = document.getElementById('hidBillCheck');
            var strSChck = document.getElementById('hidShipCheck');

            var strBAddr = document.getElementById('hidBilling');
            var strSAddr = document.getElementById('hidShipping');

            // NOTE: '*' character is used for seperation of information
            //       which will be parsed at the receiving end.

            var strBillCtrl = document.getElementById('hidBillCtrl');
            var arrBillCtrl = strBillCtrl.value.split("*");


            // Get WithState or WithOutState Billing Address Control id's
            var varBlnWithState = document.getElementById('hidBlnWithState');
            if (varBlnWithState.value == "True") {
                var citBillCtrl = document.getElementById(arrBillCtrl[0]);
                var posBillCtrl = document.getElementById(arrBillCtrl[1]);
            }
            else {
                var citBillCtrl = document.getElementById(arrBillCtrl[3]);
                var posBillCtrl = document.getElementById(arrBillCtrl[4]);
            }

            var varBillStateCtrl = document.getElementById(arrBillCtrl[2]);

            var strShipCtrl = document.getElementById('hidShipCtrl');
            var arrShipCtrl = strShipCtrl.value.split("*");

            // Get WithState or WithOutState Shipping Address Control id's
            var varShpWithState = document.getElementById('hidShpWithState');
            if (varShpWithState.value == "True") {
                var citShipCtrl = document.getElementById(arrShipCtrl[0]);
                var posShipCtrl = document.getElementById(arrShipCtrl[1]);
            }
            else {
                var citShipCtrl = document.getElementById(arrShipCtrl[3]);
                var posShipCtrl = document.getElementById(arrShipCtrl[4]);
            }

            var varShipStateCtrl = document.getElementById(arrShipCtrl[2]);

            var strBillAddr = '';
            var strShipAddr = '';

            var returnValue = '';

            var popModalFlag = document.getElementById('hidValid');

            if (popModalFlag != null && popModalFlag.value == "false") {

                var skinID = document.getElementById('hidSkinID');
                var localeSetting = document.getElementById('hidLocale');

                // Check if return flag for Billing Address has a value 
                if (strBChck.value != '') {

                    var postalCode = document.getElementById('hidBlnPostalCode');
                    var state = document.getElementById('hidBlnState');
                    var country = document.getElementById('hidBlnCountry');
                    var city = document.getElementById('hidBlnCity');
                    var withState = varBlnWithState;

                    var strQueryString = "?SkinId=" + skinID.value + "&Locale=" + localeSetting.value + "&Status=" +
                        strBChck.value + "&Title=" + strBTitl.value + "&PostalCode=" + encodeURIComponent(postalCode.value) + "&City=" +
                        encodeURIComponent(city.value) + "&State=" + state.value + "&Country=" + country.value + "&WithState=" + withState.value;

                    returnValue = window.showModalDialog("addresschecker.aspx" + strQueryString, "", "dialogWidth:585px; dialogHeight:400px; status:no; center:yes; edge:raised; scroll:off");

                    if (returnValue != '' && returnValue != null) {


                        var retBillValue = returnValue;
                        var arrBillValue = retBillValue.split("*");

                        posBillCtrl.value = arrBillValue[0];
                        citBillCtrl.value = arrBillValue[1];
                        varBillStateCtrl.value = arrBillValue[2];

                        // Check to see if Billing and Shipping Address Info are set to be the Same
                        if (strSChck.value == '' && chkAddrInfo.value == "True") {

                            document.getElementById('ctrlShippingAddress').style.display = 'none';

                            citShipCtrl.value = arrBillValue[1];
                            posShipCtrl.value = arrBillValue[0];
                            varShipStateCtrl.value = arrBillValue[2];

                        }

                    }
                }

                // Check if return flag for Shipping Address has a value which is different to that of Billing Address
                if (strSChck.value != '') {

                    var postalCode = document.getElementById('hidShpPostalCode');
                    var state = document.getElementById('hidShpState');
                    var country = document.getElementById('hidShpCountry');
                    var city = document.getElementById('hidShpCity');
                    var withState = varShpWithState;

                    var strQueryString = "?SkinId=" + skinID.value + "&Locale=" + localeSetting.value + "&Status=" +
                    strSChck.value + "&Title=" + strSTitl.value + "&PostalCode=" + encodeURIComponent(postalCode.value) + "&City=" +
                    encodeURIComponent(city.value) + "&State=" + state.value + "&Country=" + country.value + "&WithState=" + withState.value;

                    returnValue = window.showModalDialog("addresschecker.aspx" + strQueryString, "", "dialogWidth:585px; dialogHeight:400px; status:no; center:yes; edge:raised; scroll:off");

                    if (returnValue != '' && returnValue != null) {

                        var retShipValue = returnValue;
                        var arrShipValue = retShipValue.split("*");

                        citShipCtrl.value = arrShipValue[1];
                        posShipCtrl.value = arrShipValue[0];

                    }

                }

            }

        }
  
        
    </script>
</head>
<body>
    <form id="frmOnePageCheckOut" runat="server">
    <ise:InputValidatorSummary ID="errorSummary" runat="server" CssClass="error" Register="False" />
    <input type="hidden" id="hdenOnpage" />
    <asp:Literal ID="litSignin" runat="server" Mode="PassThrough"></asp:Literal>
    <table width="100%">
        <tr>
            <td valign="top" align="left">
                <asp:Image runat="server" ID="imgAccountInfo" />
                <table width="100%" id="tblAccountInfo" runat="server" cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <div style="padding: 5px 5px 5px 5px;">
                                <asp:Label ID="Label1" Text="Enter your billing information below" runat="server"
                                    Font-Bold="true" />
                            </div>
                            <hr />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Panel ID="pnlSelectBillingAddress" CssClass="AddressSelector" runat="server">
                                <asp:Label ID="lblSelectBillingAddress" Text="Select Address below:" runat="server"
                                    Font-Bold="true" />
                                <br />
                                <ise:AddressSelectorControl ID="ctrlBillingSelector" runat="server" Width="100%" />
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ise:BillingAddressControl ID="ctrlBillingAddress" runat="server" Width="100%" CaptionWidth="30%"
                                InputWidth="70%" WithStateCountyCaption="County" RegisterCountries="True" RequirePassword="False"
                                RequireCaptcha="false" RequireOver13="false" RequireOkToEmail="false" RequireSalutation="false"
                                RequireEmail="false" ShowFirstName="false" ShowLastName="false" ShowResidenceType="false" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td valign="top" align="left">
                <asp:Image runat="server" ID="imgShippingInfo" />
                <table width="100%" id="tblShippingInfo" runat="server" cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <div style="padding: 5px 5px 5px 5px;">
                                <asp:Label ID="Label3" Text="Same as Billing Info" runat="server" Font-Bold="true" />
                                <asp:CheckBox ID="chkSameAsBilling" runat="server" />
                            </div>
                            <hr />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Panel ID="pnlSelectShippingAddress" CssClass="AddressSelector" runat="server">
                                <asp:Label ID="lblSelectShippingAddress" Text="Select Address below:" runat="server"
                                    Font-Bold="true" />
                                <br />
                                <ise:AddressSelectorControl ID="ctrlShippingSelector" runat="server" Width="100%" />
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ise:AddressControl2 Width="100%" ID="ctrlShippingAddress" runat="server" CaptionWidth="30%"
                                InputWidth="70%" RegisterCountries="False" ShowFirstName="False" ShowLastName="False" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td valign="top" align="left">
                <asp:Panel ID="pnlShippingMethod" runat="server">
                    <asp:Image runat="server" ID="imgShippingMethod" />
                    <table width="100%" id="tblShippingMethod" runat="server" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <div style="padding: 5px 5px 5px 5px;">
                                    <asp:Label ID="lblSelectShippingMethod" Text="" runat="server" Font-Bold="true" />
                                    <br />
                                    <asp:Label ID="lblRefreshShippingMethod" Text="" runat="server" Font-Bold="true" />
                                </div>
                                <hr />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div style="padding: 5px 5px 5px 5px;">
                                    <ise:ShippingMethodControl ID="ctrlShippingMethod" runat="server" />
                                </div>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td valign="top" align="left">
                <asp:Panel ID="pnlPaymentTerm" CssClass="AddressSelector" runat="server">
                    <asp:Image runat="server" ID="imgPaymentTerm" />
                    <table width="100%" id="tblPaymentTerm" runat="server" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <div style="padding: 5px 5px 5px 5px;">
                                    <asp:Label ID="lblSelectPaymentTerm" Text="Please select your Payment Term below and Credit Card Information(if necessary):"
                                        runat="server" Font-Bold="true" />
                                </div>
                                <hr />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <ise:PaymentTermControl ID="ctrlPaymentTerm" runat="server" CardTypeCaption="Card Type"
                                    CVVCaption="Credit Card Verification Code" />
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td align="center" valign="top">
                <asp:Button ID="btnCompletePurchase" runat="server" Text="Complete Purchase" OnClick="btnCompletePurchase_Click" />
            </td>
        </tr>
        <tr>
            <td align="center" valign="top">
                <asp:Panel ID="pnlOrderSummary" runat="server" HorizontalAlign="Center">
                    <asp:Literal ID="OrderSummary" Mode="PassThrough" runat="server"></asp:Literal>
                </asp:Panel>
            </td>
        </tr>
    </table>
    <input type="hidden" id="hidCheck" value="true" runat="server" />
    <input type="hidden" id="hidValid" value="true" runat="server" />
    <input type="hidden" id="hidShipTitle" runat="server" />
    <input type="hidden" id="hidBillTitle" runat="server" />
    <input type="hidden" id="hidShipCheck" runat="server" />
    <input type="hidden" id="hidBillCheck" runat="server" />
    <input type="hidden" id="hidShipping" runat="server" />
    <input type="hidden" id="hidBilling" runat="server" />
    <input type="hidden" id="hidShipCtrl" runat="server" />
    <input type="hidden" id="hidBillCtrl" runat="server" />
    <input type="hidden" id="hidShpState" runat="server" />
    <input type="hidden" id="hidShpCountry" runat="server" />
    <input type="hidden" id="hidShpPostalCode" runat="server" />
    <input type="hidden" id="hidShpCity" runat="server" />
    <input type="hidden" id="hidShpWithState" runat="server" />
    <input type="hidden" id="hidBlnState" runat="server" />
    <input type="hidden" id="hidBlnCountry" runat="server" />
    <input type="hidden" id="hidBlnPostalCode" runat="server" />
    <input type="hidden" id="hidBlnCity" runat="server" />
    <input type="hidden" id="hidBlnWithState" runat="server" />
    <input type="hidden" id="hidSkinID" runat="server" />
    <input type="hidden" id="hidLocale" runat="server" />
    </form>
</body>
</html>
